//字符串轮转
class Solution {
public:
    bool isFlipedString(string s1, string s2) 
    {
        int m=s1.size(); int n=s2.size();
        if(m!=n) return false;
        if(s1.empty()) return true;
        for(int i=0;i<n;i++)
        {
            bool flag=true;
            for(int j=0;j<n;j++)
            {
                if(s1[(i+j)%n]!=s2[j])
                {
                    flag=false;
                    break;
                }
            }
            if(flag) return true;
        }
        return false;
    }
};
//堆盘子
class StackOfPlates {
public:
    StackOfPlates(int cap)
        :_capacity(cap) 
    {}
    
    void push(int val) 
    {
        if(_capacity==0) return;
        if(_v.empty() || _v.back()->size()==_capacity)
        {
            stack<int>* st=new stack<int>();
            _v.push_back(st);
        }
        _v.back()->push(val);

    }
    
    int pop() 
    {

        if(_capacity==0 || _v.empty()) return -1;
        int res=_v.back()->top();
        _v.back()->pop();
        if(_v.back()->empty()) _v.pop_back();
        return res;

    }
    
    int popAt(int index) 
    {
        if(_capacity==0 || index>= _v.size() || _v[index]->empty()) return -1;
        int res=_v[index]->top();
        _v[index]->pop();
        if(_v[index]->empty()) _v.erase(_v.begin()+index);
        return res;
    }
private:
    vector<stack<int>*>_v;
    int _capacity;
};
//删除中间节点
class Solution {
public:
    void deleteNode(ListNode* node) 
    {
        //node 不是链表头结点 而是要删除的节点
        //思路：将后一个节点的值拷贝到node 再将后一个节点删除
        node->val=node->next->val;
        node->next=node->next->next;
    }
};